<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #box{
            width: 300px;
            height: 50px;
            border: 3px solid #c92007;
            margin-left: 200px;
            margin-top: 50px;
            color: #c92007;
            line-height: 50px;
            text-align: center;
        }
    </style>
</head>
<body>
    <div id="box"></div>
    <script>
        // 倒计时，  给定一个未来的日期，
        // 计算和当前时间的差值，并倒计时， 当倒计时为0时， 弹出提示框“活动结束”
        var oBox=document.getElementById("box");
        var date=new Date(2021,8,15,21,25,30);

        var timer=setInterval(function(){
                var time=new Date();
                var num=date-time;
                s=parseInt(num/1000)%60;
                m=parseInt(num/1000/60)%60;
                h=parseInt(num/1000/60/60)%24;
                d=parseInt(num/1000/60/60/24);
                if(num<=0){
                    clearInterval(timer);
                    alert("活动结束");
                    d=0+"0";
                    m=0+"0";
                    h=0+"0";
                    d=0+"0";
                }
                var res="倒计时:"+d+"天/"+h+"时/"+m+"分/"+s+"秒";
                oBox.innerHTML=res;
            });


    </script>
</body>
</html>